//
//  DWBlockViewController.m
//  OCAPPDemo
//
//  Created by 杨冬武 on 2021/4/1.
//

#import "DWBlockViewController.h"
#import <objc/runtime.h>

@interface DWBlockViewController ()

@property (nonatomic, assign) int age;

@end

@implementation DWBlockViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    __weak typeof(self) weakSelf = self;
    NSLog(@"%@", [[^{ NSLog(@"%d", weakSelf.age); } class] superclass]);
    
    int a = 0;
    void (^block1)(void) = ^{
        NSLog(@"%d", a);
    };
    NSLog(@"%@", [block1 class]);
}

- (void)test {
    NSMutableString *str = [[NSMutableString alloc] initWithString:@"hello"];
    
    void (^block)(void) = ^{
        [str appendString:@" world"];
        //str = [[NSMutableString alloc] initWithString:@"aaa"]; //不允许,需要使用 __block
        NSLog(@"%@", str);
    };
 
    NSLog(@"%@", str);
    
    block();
}
- (IBAction)clickButton:(id)sender {
    
}

@end
